#include "menulabel.h"

QFont MenuLabel::menuLabelFont("arial", 24);

MenuLabel::MenuLabel(QString text, int windowCenter, int y, QWidget *parent) :
    QLabel(text, parent)
{
    setFont(menuLabelFont);
    enabled = true;
    setGeometry(windowCenter - (sizeHint().width() / 2), y, sizeHint().width(), sizeHint().height());
    setStyleSheet(" color: white; ");
}

MenuLabel::MenuLabel(QString text, QWidget *parent) :
    QLabel(text, parent)
{
    setFont(menuLabelFont);
    enabled = true;
    setStyleSheet(" color: white; ");
}

void MenuLabel::setEnabled(bool b) {
    enabled = b;

    if(enabled) setStyleSheet(" color: white; ");
    else setStyleSheet(" color: darkgray; ");
}

void MenuLabel::setDisabled(bool b) {
    enabled = !b;

    if(enabled) setStyleSheet(" color: white; ");
    else setStyleSheet(" color: rgb(32, 32, 32); ");
}

void MenuLabel::mousePressEvent(QMouseEvent *event) {
    if(enabled) {
        setStyleSheet(" color: red; ");
        repaint();
    }
}

void MenuLabel::mouseReleaseEvent(QMouseEvent *event) {
    if(enabled) {
        Sound::playSound("click");

        setStyleSheet(" color: yellow; ");
        repaint();
        emit clicked();
    }
}

void MenuLabel::enterEvent(QEvent *event) {
    if(enabled) {
        Sound::playSound("tick");

        setStyleSheet(" color: yellow; ");
        repaint();
    }
}

void MenuLabel::leaveEvent(QEvent *event) {
    if(enabled) {
        setStyleSheet(" color: white; ");
        repaint();
    }
}
